/*
** event_monitor.c for Event_monitor in /home/vriely/Dropbox/work/Unix/Zappy_rendu/serv-src
**
** Made by Samuel Vrielynck
** Login   <vriely_s@epitech.net>
**
** Started on  Tue Jul 10 14:51:28 2012 Samuel Vrielynck
** Last update Thu Jul 19 17:33:16 2012 pierrick druart
*/

#include			"server.h"

static const t_handle_event_mnt	tab_event[] =
{
  { CONNECT_MNT, &handle_connect_mnt },
  { EXPULSE_MNT, &handle_expulse_mnt },
  { INCANT_MNT, &handle_incant_mnt},
  { INVENT_MNT, &handle_invent_mnt},
  { LEVEL_MNT, &handle_level_mnt}
};

void				check_event_mnt(t_list *clients, t_game *game)
{
  t_event			*event;
  t_item			*cur;

  if (game->event_mnt->len > 0)
  {
    cur = game->event_mnt->head;
    while (cur != NULL)
    {
      event = (struct s_event *)cur->content;
      if (tab_event[event->type].func(game, clients, event) == 0)
	cur = game->event_mnt->erase(game->event_mnt, cur, erase_event_mnt);
      if (cur != NULL)
	cur = cur->next;
    }
  }
}
